package com.openlab.service.moveCar.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.openlab.service.moveCar.dto.Detail;
import com.openlab.service.moveCar.dto.Info;
import com.openlab.service.moveCar.dto.ListDto;
import com.openlab.service.moveCar.eneity.MoveCar;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MoveCarMapper extends BaseMapper<MoveCar> {
    @Select("select ejyy_move_car.id," +
            "ejyy_move_car.car_number," +
            "ejyy_move_car.move_reason," +
            "ejyy_move_car.live_img," +
            "ejyy_move_car.subscribed," +
            "ejyy_move_car.have_concat_info," +
            "ejyy_move_car.response_user_id," +
            "ejyy_move_car.response_content," +
            "ejyy_move_car.responsed_at," +
            "ejyy_move_car.created_at," +
            "ejyy_wechat_mp_user.real_name as wechat_mp_user_real_name," +
            "ejyy_wechat_mp_user.id as wechat_mp_user_id," +
            "ejyy_property_company_user.real_name as property_company_user_real_name," +
            "ejyy_property_company_user.id as property_company_user_id "+
            "from ejyy_move_car "+
            "left join ejyy_wechat_mp_user on ejyy_wechat_mp_user.id = ejyy_move_car.wechat_mp_user_id "+
            "left join ejyy_property_company_user on ejyy_property_company_user.id = ejyy_move_car.response_user_id "+
            "where ejyy_move_car.id=#{id} and ejyy_move_car.community_id = #{community_id}")
    Info detailInfo(@Param("id") Long id, @Param("community_id") Long community_id);

    @Select("select ejyy_move_car.id,"+
            "ejyy_move_car.car_number,"+
            "ejyy_move_car.move_reason,"+
            "ejyy_move_car.have_concat_info,"+
            "ejyy_move_car.responsed_at,"+
            "ejyy_move_car.created_at "+
            "from ejyy_move_car "+
            "where ejyy_move_car.community_id = #{community_id}  ")
    List<ListDto> getList(@Param("community_id") Long community_id);

    @Select("select * from ejyy_move_car "+
            "where ejyy_move_car.id = #{id} and ejyy_move_car.community_id = #{community_id}")
    Detail getDetail(@Param("id")Long id, @Param("community_id")Long community_id);
}
